<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.List"%>
<%@page import="com.model.Menu"%>
<%@page import="com.model.Role"%><html>
<head>
<link href="./css/ltcss.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PayChannel</title>
<link href="styles/general.css" rel="stylesheet" type="text/css">
<link href="styles/main.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/validator.js"></script>
<script>
function txcheck(){
	return formvalidator("all");
}
function formvalidator(obj)
{
	var controlId = "all";
	 if (typeof(obj) != "string" )
	 {
		 controlId = obj.id;
	 }
	if(controlId=="all" || controlId=="model.loginName")
	{
		if(Utils.trim(document.getElementById("model.loginName").value)=="")
		{
			document.getElementById("CompareValidator1").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator1").style.visibility="hidden";
		}
	}
	if(controlId=="all" || controlId=="model.password")
	{
		if(Utils.trim(document.getElementById("model.password").value)=="")
		{
			document.getElementById("CompareValidator2").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator2").style.visibility="hidden";
		}
	}
	if(controlId=="all" || controlId=="model.name")
	{
		if(Utils.trim(document.getElementById("model.name").value)=="")
		{
			document.getElementById("CompareValidator3").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator3").style.visibility="hidden";
		}
	}
	if(controlId=="all" || controlId=="model.roleId")
	{
		if(Utils.trim(document.getElementById("model.roleId").value)=="")
		{
			document.getElementById("CompareValidator4").style.visibility="visible";
			return false;
		}
		else
		{
			document.getElementById("CompareValidator4").style.visibility="hidden";
		}
	}
	return true;
}

function chkAll(vl,name)
{
	var v = document.getElementsByName(name);
	for(var i=0;i<v.length;i++)
	{
		v[i].checked=vl;
	}
	
}

function spcpDiv(vl)
{
	document.getElementById('model.isAdmin').value=vl;
	var spdiv = document.getElementById('spDiv');
	var cpdiv = document.getElementById('cpDiv');
	//var spdiv1 = document.getElementById('spDiv1');
	//var cpdiv1 = document.getElementById('cpDiv1');
	if(vl==true)
	{
		spdiv.style.display='none';
		cpdiv.style.display='none';
	//	spdiv1.style.display='none';
	//	cpdiv1.style.display='none';
	}
	else
	{
		spdiv.style.display='block';
		cpdiv.style.display='block';
	//	spdiv1.style.display='block';
	//	cpdiv1.style.display='block';
	}
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="admin_save.do?type=<s:if test="type.equals('upd')">update</s:if><s:else>add</s:else>" onsubmit="return txcheck();">
 <input type="hidden" name="model.id" id="model.id" value="<s:property value="model.id"/>" />
 <input type="hidden" name="txt_keyword" id="txt_keyword" value="<s:property value="txt_keyword"/>" />
 <h1>
        <span class="action-span"><a href="admin_list.do?txt_keyword=<s:property value="txt_keyword"/>">用户列表</a></span> <span
            class="action-span1"><a href="">
                首页</a> </span><span id="search_id" class="action-span1">- 用户管理 </span>
        <div style="clear: both">
        </div>
    </h1>
 <div style="margin-bottom: 5px;" class="list-div">
        <table width="100%" cellspacing="1" cellpadding="3">
            <tbody>
                <tr>
                    <th colspan="2">
                        基本信息
                    </th>
                </tr>
                <tr> 
				    <td  class="label"><div align="right">用户名：</div></td> 
				    <td>
					    <input type="text" size="20" name="model.loginName" id="model.loginName" onblur="formvalidator(this)" value="<s:property value="model.loginName"/>"/>
						<span
                           class="require-field">*</span>&nbsp;
                        <span id="CompareValidator1" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  <tr> 
				    <td class="label"><div align="right">密码：</div></td> 
				    <td >
					    <input type="password" size="20" name="model.password" id="model.password" onblur="formvalidator(this)" value="<s:property value="model.password"/>"/>
						<span
                           class="require-field">*</span>&nbsp;
                        <span id="CompareValidator2" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  
				  <tr> 
				    <td  class="label"><div align="right">姓名：</div></td> 
				    <td>
					    <input type="text" size="20" name="model.name" id="model.name" onblur="formvalidator(this)" value="<s:property value="model.name"/>"/>
						<span
                           class="require-field">*</span>&nbsp;
                        <span id="CompareValidator3" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  <tr> 
				    <td class="label" ><div align="right">角色：</div></td> 
				    <td>
					     <select name="model.roleId" id="model.roleId" onchange="formvalidator(this)">
					    	<option value="">--请选择角色--</option>
					    	<s:iterator value="roleList" status="ri">
					    		<option value="<s:property value="id"/>" <s:if test='id.equals(model.roleId)'>selected</s:if>><s:property value="roleName"/></option>
					    	</s:iterator>
					    </select>
						<span
                           class="require-field">*</span>&nbsp;
                        <span id="CompareValidator4" style="color:Red;visibility:hidden;">不能为空</span><br />
                    </td>
				  </tr>
				  <tr> 
				    <td  class="label"><div align="right">Is Admin：</div></td> 
				    <td>
					    <input type="hidden" id="model.isAdmin" name="model.isAdmin" 
					    value="<s:if test="model['isAdmin']==''" >flase</s:if><s:else><s:property value="model.isAdmin" /></s:else>" />
    					<input type="checkbox" name="spcpdiv" id="spcpdiv" <s:if test="'true'.equals(model.isAdmin)">checked</s:if> onclick="spcpDiv(this.checked)" />
                    </td>
				  </tr>
				  <tr> 
				    <td style="vertical-align: top;" class="label"><div align="right"><input onclick="chkAll(this.checked,'channel_checkbox');" type="checkbox"/>关联渠道：</div></td> 
				    <td>
				    	<table cellpadding="0" cellspacing="0" border="0">
				    		<tr>
				    		<s:iterator status="i" value="chlist">
				    		<s:if test="#i.index!=0&&#i.index%7==0"></tr><tr></s:if>
				    		<td><input type="checkbox" name="channel_checkbox" <s:if test="chstr.indexOf(','+id+',')!=-1">checked</s:if> value="<s:property value="id"/>" /><s:property value="name"/></td>
				    		</s:iterator>
				    		</tr>
				    	</table>
                    </td>
				  </tr>
				  <tr>
                    <td colspan="2" align="center">
                     <s:if test="isUpdate.equals('true')">
					    <input type="submit" value=" 确定 " class="button" />
					 </s:if>
                        &nbsp;&nbsp;&nbsp;
                        <input type="reset" value=" 重置 " class="button" />
                    </td>
                </tr>
	 	</tbody>
	 </table>
 </div>
</form>
 <!--Bottom开始-->
    
<div id="footer">
<br />
<s:property value="bottom"/></div>
    <!--Bottom结束-->
  
</body>
</html>